package com.atguigu.day05;

public class Test06 {
    public static void main(String[] args) {
        int[] arr1 = new int[]{1, 2, 3, 4, 3, 2, 1};
        int[] subarr = new int[]{1, 2, 3, 4, 5, 2, 1};
        issame(arr1);
        issame(subarr);
    }

    static void issame(int arr[]) {
        int half;
        boolean issame = true;
        System.out.print("是否对称:");
        if (arr.length % 2 == 0) {
            half = arr.length / 2;
        } else
            half = (arr.length + 1) / 2;
        for (int i = 0; i <= half; i++) {
            if (arr[i] != arr[arr.length - i - 1]) {
                issame = false;
            }
        }
        if (issame)
            System.out.println(true);
        else
            System.out.println(false);
    }
}
